﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using ProtoImaginer;

namespace ProtoImaginer.ProtoProject
{
    public partial class ViewProject : PhoneApplicationPage
    {
        public ViewProject()
        {
            InitializeComponent();
        }
        string projectIdToSend = "";
        int selectedIndex = -1;
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            String parameterString = NavigationContext.QueryString["selectedItem"];
            selectedIndex = int.Parse(parameterString);
            NoticeTextBlock.Text = "There are no pages for this project " + MainPage.MyProjects[selectedIndex].ProjectName;
            projectIdToSend = MainPage.MyProjects[selectedIndex].ProjectId;
        }

        private void EditProjectClick(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/ProtoProject/EditProject.xaml?projectIdToSend=" + projectIdToSend, UriKind.Relative));
        }

        private void AddPageClick(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/ProtoImage/AddPhoto.xaml?projectIdToSend=" + projectIdToSend, UriKind.Relative));
        }

        private void PlayButtonClick(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/ProtoDemo/ProjectDemo.xaml?PageIdToSend=-1" /* should be id of the first page in this project*/, UriKind.Relative));
        }
    }
}